﻿Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Workflow.ComponentModel

Namespace System.Workflow.ComponentModel.Design
    <ActivityDesignerTheme(GetType(FaultHandlerActivityDesignerTheme))> _
    Friend NotInheritable Class FaultHandlerActivityDesigner
        Inherits SequentialActivityDesigner
        ' Methods
        Public Overrides Function CanBeParentedTo(ByVal parentActivityDesigner As CompositeActivityDesigner) As Boolean
            If (parentActivityDesigner Is Nothing) Then
                Throw New ArgumentNullException("parentActivityDesigner")
            End If
            Return (TypeOf parentActivityDesigner.Activity Is FaultHandlersActivity AndAlso MyBase.CanBeParentedTo(parentActivityDesigner))
        End Function

        Protected Overrides Sub OnActivityChanged(ByVal e As ActivityChangedEventArgs)
            MyBase.OnActivityChanged(e)
            If ((Not e.Member Is Nothing) AndAlso String.Equals(e.Member.Name, "FaultType", StringComparison.Ordinal)) Then
                TypeDescriptor.Refresh(e.Activity)
            End If
        End Sub

        Protected Overrides Sub PreFilterProperties(ByVal properties As IDictionary)
            MyBase.PreFilterProperties(properties)
            If (properties.Item("InitializeField") Is Nothing) Then
                properties.Item("InitializeField") = TypeDescriptor.CreateProperty(MyBase.GetType, "InitializeField", GetType(Boolean), New Attribute() { DesignerSerializationVisibilityAttribute.Hidden, BrowsableAttribute.No })
            End If
        End Sub


        ' Properties
        Public Overrides ReadOnly Property CanExpandCollapse As Boolean
            Get
                Return False
            End Get
        End Property

        Private ReadOnly Property InitializeField As Boolean
            Get
                Return False
            End Get
        End Property

        Public Overrides ReadOnly Property Views As ReadOnlyCollection([Of] DesignerView)
            Get
                Dim list As New List([Of] DesignerView)
                Dim view As DesignerView
                For Each view In MyBase.Views
                    If (((view.ViewId <> 2) AndAlso (view.ViewId <> 3)) AndAlso (view.ViewId <> 4)) Then
                        list.Add(view)
                    End If
                Next
                Return New ReadOnlyCollection([Of] DesignerView)(list)
            End Get
        End Property

    End Class
End Namespace

